﻿using Eneta.Portal.Forum.Core.Data;
using Eneta.Portal.Forum.Core.Domain.Collections;
using Eneta.Portal.Forum.Core.Domain.Entities;
using Microsoft.SharePoint;

namespace Eneta.Portal.Forum.Core.Domain.Repositories
{
    public class CategoryRepository
    {
        // Fields
        private readonly CategoryDao _dao = new CategoryDao();

        // Methods
        public CategoryCollection GetAll()
        {
            return _dao.GetAll();
        }

        public Category GetById(int id)
        {
            return _dao.GetById(id);
        }

        public CategoryCollection GetVisibleCategoriesForUser(SPUser user)
        {
            return _dao.GetAll();
        }

        public void Save(CategoryCollection collection)
        {
            foreach (Category category in collection)
            {
                _dao.Save(category);
            }
        }

        public int Save(Category category)
        {
            return _dao.Save(category);
        }
    }
}
